import request from "@/request";

//获取所有角色列表接口
export const getAllRoleList = ()=>{
    return request.get('/roleManager/getRoleList')
}

//获取角色的父级权限列表接口
export const getRoleParentAuthList = (roleName)=>{
    let params = new URLSearchParams()
    params.append('roleName',roleName)
    return request.get('/roleManager/getRoleParentAuthList', {params})
}

//获取父级权限的子权限列表接口
export const getRoleChildAuthList = (pidName)=>{
    let params = new URLSearchParams()
    params.append('pidName',pidName)
    return request.get('/authManager/getChildAuthList', {params})
}

//禁用角色接口
export const forbiddenRole = (roleName)=>{
    let params = new URLSearchParams()
    params.append('roleName',roleName)
    return request.get('/roleManager/forbiddenRole', {params})
}

//解禁角色接口
export const unForbiddenRole = (roleName)=>{
    let params = new URLSearchParams()
    params.append('roleName',roleName)
    return request.get('/roleManager/unForbiddenRole', {params})
}

//添加角色接口
export const addRole = (roleName)=>{
    let params = new URLSearchParams()
    params.append('roleName',roleName)
    return request.put('/roleManager/addRole', params)
}

//删除角色接口
export const deleteRole = (roleName)=>{
    let params = new URLSearchParams()
    params.append('roleName',roleName)
    return request.delete('/roleManager/removeRole', {params})
}

//修改角色接口
export const editRole = (roleName,newName)=>{
    let params = new URLSearchParams()
    params.append('roleName',roleName)
    params.append('newName',newName)
    return request.post('/roleManager/editRole', params)
}

//添加父级权限接口
export const addRoleParentAuth = (roleName,authPidName)=>{
    let params = new URLSearchParams()
    params.append('roleName',roleName)
    params.append('authPidName',authPidName)
    return request.post('/roleManager/addAuthsToRole', params)
}

//删除父级权限接口
export const deleteRoleParentAuth = (roleName,authPidName)=>{
    let params = new URLSearchParams()
    params.append('roleName',roleName)
    params.append('authPidName',authPidName)
    return request.delete('/roleManager/removeAuthsGroupOfRole', {params})
}

//一键删除角色权限接口
export const deleteRoleAllAuth = (roleName)=>{
    let params = new URLSearchParams()
    params.append('roleName',roleName)
    return request.delete('/roleManager/removeAllAuthsOfRole', {params})
}

//一键添加角色权限接口
export const addRoleAllAuth = (roleName)=>{
    let params = new URLSearchParams()
    params.append('roleName',roleName)
    return request.put('/roleManager/addAllAuthsToRole', params)
}